package com.example.websocket.model;


public class MessageData<T> {
    /**
     * 事件类型
     */
    String type;
    /**
     * 接收事件处理的模块
     */
    String model;
    /**
     * 具体业务数据
     */
    T data;

    /**
     * 操作状态码
     */
    private Integer code;


    public MessageData(String type,String model){
        this.type = type;
        this.model = model;
        this.data=null;
        this.code = 200;
    }

    public MessageData(String type,String model,Integer code){
        this.type = type;
        this.model = model;
        this.code = code;
        this.data = null;
    }

    public MessageData(String type,String model,T data){
        this.type = type;
        this.model = model;
        this.code = 200;
        this.data = data;
    }

    public MessageData(String type,String model,T data,Integer code){
        this.type = type;
        this.model = model;
        this.code = code;
        this.data = data;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String toString() {
        return "MessageData{" +
                "type='" + type + '\'' +
                ", model='" + model + '\'' +
                ", data=" + data +
                ", code=" + code +
                '}';
    }
}
